package appreate.sixnations.quiz.utils;

import java.util.ArrayList;

import android.content.Context;
import appreate.sixnations.quiz.R;

public class Commons {
	private static Commons _instance;

	public static final int EASY = 0;
	public static final int NORMAL = 1;
	public static final int HARD = 2;

	private Commons() {
	}

	public static Commons getInstance() {

		if (_instance == null) {
			_instance = new Commons();
		}
		return _instance;
	}

	public String searchFlag(Context context, ArrayList<String> history, int mode) {
		String[] temp;
		if (mode == EASY) {
			temp = context.getResources().getStringArray(R.array.easy);
		} else if (mode == NORMAL) {
			temp = context.getResources().getStringArray(R.array.normal);
		/*} else if (mode == HARD) {
			temp = context.getResources().getStringArray(R.array.hard);*/
		} 
		else {
			temp = context.getResources().getStringArray(R.array.all);
		}

		if (temp != null && temp.length > history.size()) {
			while (true) {

				double numberDouble = Math.random() * temp.length;
				int number = (int) numberDouble;

				if (history.size() == 0 || !history.contains(temp[number])) {
					return temp[number];
				}

			}
		} else {
			return null;
		}

	}

}
